package main

import "fmt"

func lengthOfNonRepeatingSubStr(s string) int  {
	lastOccurred := make(map[rune]int)
	start := 0
	maxLength := 0
	for i,ch := range []rune (s) {

		if lastI , ok := lastOccurred[ch];
		ok && lastI >= start  {
			start = lastOccurred[ch] + 1
		}

		if i-start+1 > maxLength {
			maxLength = i - start + 1
		}

		lastOccurred[ch] = i

	}
	return maxLength
}

func main() {
	fmt.Println(lengthOfNonRepeatingSubStr("我爱慕课玩"))
	fmt.Println(lengthOfNonRepeatingSubStr("我我是我是一个大话就"))
	fmt.Println(lengthOfNonRepeatingSubStr("我我我我我"))

}
